package jnpf.engine.custom.event.flusher;

import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.event.logger.AbstractEventFlusher;
import org.flowable.engine.impl.event.logger.handler.EventLoggerEventHandler;
import org.flowable.engine.impl.persistence.entity.EventLogEntryEntity;
import org.flowable.engine.impl.persistence.entity.EventLogEntryEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;

public class ElasticSearchFlusher extends AbstractEventFlusher {
    @Override
    public void closing(CommandContext commandContext) {
        EventLogEntryEntityManager eventLogEntryEntityManager = CommandContextUtil.getEventLogEntryEntityManager();
        for (EventLoggerEventHandler eventHandler : eventHandlers) {
            EventLogEntryEntity eventLogEntryEntity = eventHandler.generateEventLogEntry(commandContext);
//            eventLogEntryEntityManager.insert(eventHandler.generateEventLogEntry(commandContext));
        }
    }

    @Override
    public void afterSessionsFlush(CommandContext commandContext) {

    }

    @Override
    public void closeFailure(CommandContext commandContext) {

    }

    @Override
    public Integer order() {
        return 200;
    }

    @Override
    public boolean multipleAllowed() {
        return false;
    }
}
